package ${package.ServiceImpl};

import org.springframework.beans.BeanUtils;
import ${package.Entity}.*;
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author ${author}
 * @since ${date}
 */
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

    @Autowired
    private ${table.mapperName} ${(table.mapperName)?uncap_first};

    /**
    * 分页
    */
    @Override
    public IPage<${entity}DTO> page(${entity}SearchForm form){
        IPage<${entity}DTO> iPage = ${(table.mapperName)?uncap_first}.list(form.getPage());

        return iPage;
    }

    /**
    * 添加
    */
    @Override
    @Transactional
    public void add(${entity}AddForm form){
        ${entity} ${entity?uncap_first} = new ${entity}();
        BeanUtils.copyProperties(form, ${entity?uncap_first});

        ${(table.mapperName)?uncap_first}.insert(${entity?uncap_first});
    }

    /**
    * 删除
    */
    @Override
    @Transactional
    public void delete(Long id){
        ${entity} ${entity?uncap_first} = new ${entity}();
        ${entity?uncap_first}.setId(id);
        ${entity?uncap_first}.setIsDeleted(1);

        ${(table.mapperName)?uncap_first}.updateById(${entity?uncap_first});
    }

    /**
    * 修改
    */
    @Override
    @Transactional
    public void update(${entity}UpdateForm form){
        ${entity} ${entity?uncap_first} = new ${entity}();
        BeanUtils.copyProperties(form, ${entity?uncap_first});

        ${(table.mapperName)?uncap_first}.updateById(${entity?uncap_first});
    }

    /**
    * 详情
    */
    @Override
    public ${entity}DTO getById(Long id){
        ${entity}DTO ${entity?uncap_first}DTO = ${(table.mapperName)?uncap_first}.getById(id);

        return ${entity?uncap_first}DTO;
    }

}
</#if>
